package Com.javaserver.servlet;

import Com.javaserver.bean.departmentinquire;
import Com.javaserver.bean.invite;
import Com.javaserver.dao.departmentserver;
import Com.javaserver.dao.inviteserver;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/delelist")
public class inviteDeleteserverlet extends HttpServlet {
  inviteserver invited=new inviteserver();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    //招聘的删除接口
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        Integer indele = Integer.parseInt(req.getParameter("delete"));
        invite invitein = new invite();
        invitein.setC_id(indele);
        inviteserver invi = new inviteserver();
        if (!invited.delelist(invitein)) {
            req.getSession().setAttribute("msg", "删除失败");
            resp.sendRedirect(req.getContextPath() + "/Recruitment.jsp");
        } else {
            req.getSession().setAttribute("msg", "删除成功");
            List<invite> list = invi.inlist(1);
            req.getSession().setAttribute("invitlist", list);
            req.getSession().setAttribute("nav", "招聘管理");
            resp.sendRedirect(req.getContextPath() + "/inlist");
        }
    }
}
